﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using RichTextFormatter.ColorRichTextBox;

namespace GestorSQL.GUI
{
    public partial class TextWindow : Form
    {
        public string Texto { get; private set; }
        public bool requiereConfirmacion;


        public TextWindow(string title, string text, string label, bool _readonly, bool _darFormato, bool _requiereConfirmacion)
        {
            InitializeComponent();
            this.Text = title;
            this.lbl_Texto.Text = label;
            this.txt_Texto.Text = text;
            this.txt_Texto.ReadOnly = _readonly;
            this.requiereConfirmacion = _requiereConfirmacion;

            if (_darFormato)
            {
                clsColorRichTextBoxSchema schema = new clsColorRichTextBoxSchema(clsColorRichTextBoxSchema.enColorSchemaType.SQL);
                clsColorRichTextBox m_ColorRTB = new RichTextFormatter.ColorRichTextBox.clsColorRichTextBox(txt_Texto, schema);
                m_ColorRTB.RecolorEntireText();

            }

        }

        private void btAceptar_Click(object sender, EventArgs e)
        {

            Texto = txt_Texto.Text;
            if (requiereConfirmacion && Texto.Equals(string.Empty))
                MessageBox.Show(Properties.Resources.TextWindow_RequiereDescripcion);
            else
            {
                this.DialogResult = DialogResult.OK;
                this.Close();
            }
        }

        private void btCancelar_Click(object sender, EventArgs e)
        {
            this.DialogResult = DialogResult.Cancel;
            this.Close();
        }
    }
}
